package com.ruoyi.energy.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.energy.domain.NyCheckSum;
import com.ruoyi.energy.domain.vo.NyCheckSumVO;
import com.ruoyi.energy.service.INyCheckMeterService;
import com.ruoyi.energy.service.INyCheckSumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 私汇总Controller
 *
 * @author cjie
 * @date 2021-11-12
 */
@Api(tags = " 私表汇总")
@RestController
@RequestMapping("/nyCheckSum")
public class NyCheckSumController extends BaseController {
    @Autowired
    private INyCheckSumService nyCheckSumService;

    @Autowired
    private INyCheckMeterService nyCheckMeterService;

    /**
     * 查询私汇总列表
     */
    @ApiOperation(value="查询私汇总列表", notes="查询私汇总列表")
    @PreAuthorize(hasPermi = "energy:nyCheckSum:list")
    @GetMapping("/list")
    public TableDataInfo list(NyCheckSum nyCheckSum) {
        startPage();
        List<NyCheckSumVO> list = nyCheckSumService.selectNyCheckSumVOList(nyCheckSum);
        return getDataTable(list);
    }

    /**
     * 查询私汇总列表

    @ApiOperation(value="查询私汇总列表", notes="查询私汇总列表")
    @PreAuthorize(hasPermi = "energy:nyCheckSum:list")
    @GetMapping("/list2")
    public TableDataInfo compute2(NyCheckMeter nyCheckMeter) {
        NyCheckSumVO node = nyCheckMeterService.computeNyMeterSummary(nyCheckMeter);
        List<NyCheckSumVO> list = new ArrayList<NyCheckSumVO>();
        list.add(node);
        return getDataTable(list);
    }*/

    /**
     * 获取私汇总详细信息
     *//*
    @ApiOperation(value="获取私汇总详细信息", notes="获取私汇总详细信息")
    @PreAuthorize(hasPermi = "energy:nyCheckSum:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(nyCheckSumService.selectNyCheckSumById(id));
    }*/

    /**
     * 累加私汇总,修改总表汇总记录状态，仪表台账添加
     */
//    @ApiOperation(value="累加私汇总", notes="累加私汇总")
//    @ApiImplicitParam(name = "ids", value = "私汇总ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
//    @PreAuthorize(hasPermi = "energy:nyCheckSum:remove")
//    @Log(title = "私汇总", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult addShare(@PathVariable String[] ids) {
//        return toAjax(nyCheckSumService.addNyCheckSumByIds(ids));
//    }

    /**
     * 保存私汇总
     */
    @ApiOperation(value="插入汇总记录", notes="插入汇总记录")
    @Log(title = "插入汇总记录", businessType = BusinessType.INSERT)
    @PostMapping("/logs")
    public AjaxResult insertComputeLogs(@RequestBody List<NyCheckSumVO> nyCheckSumVOs) {
        return toAjax(nyCheckSumService.insertComputeLogs(nyCheckSumVOs));
    }

    /**
     * 删除私汇总
     */
    @ApiOperation(value="删除私汇总", notes="删除私汇总")
    @ApiImplicitParam(name = "ids", value = "私汇总ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:nyCheckSum:remove")
    @Log(title = "私汇总", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(nyCheckSumService.deleteNyCheckSumByIds(ids));
    }

}
